/*
  学习目标：多表单元素代码优化- 初级版
*/
import React, { Component } from 'react';

export default class App extends Component {
  state = {
    name: 'zs',
    intro: '狂徒',
    city: '3',
    isSingle: true,
  };

  handleChange = (e) => {
    this.setState({ [e.target.name]: e.target.value });
  };

  handleChangeSingle = (e) => {
    this.setState({ isSingle: e.target.checked });
  };
  render() {
    const { name, intro, city, isSingle } = this.state;
    return (
      <div>
        姓名：
        <input name="name" value={name} type="text" onChange={this.handleChange} />
        <br />
        描述：<textarea name="intro" value={intro} onChange={this.handleChange}></textarea>
        <br />
        城市：
        <select name="city" value={city} onChange={this.handleChange}>
          <option value="1">北京</option>
          <option value="2">上海</option>
          <option value="3">广州</option>
          <option value="4">深圳</option>
        </select>
        <br />
        是否单身：
        <input checked={isSingle} onChange={this.handleChangeSingle} type="checkbox" />
      </div>
    );
  }
}
